package com.ruoyi.web.controller.kiku;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.kiku.domain.KikuBaseInfo;
import com.ruoyi.kiku.service.IKikuBaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 小鞠基本信息Controller
 *
 * @author TT
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/kiku/baseInfo")
public class KikuBaseInfoController extends BaseController
{
    @Autowired
    private IKikuBaseInfoService kikuBaseInfoService;

    /**
     * 查询小鞠基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:baseInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(KikuBaseInfo kikuBaseInfo)
    {
        startPage();
        List<KikuBaseInfo> list = kikuBaseInfoService.selectKikuBaseInfoList(kikuBaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出小鞠基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:baseInfo:export')")
    @Log(title = "小鞠基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KikuBaseInfo kikuBaseInfo)
    {
        List<KikuBaseInfo> list = kikuBaseInfoService.selectKikuBaseInfoList(kikuBaseInfo);
        ExcelUtil<KikuBaseInfo> util = new ExcelUtil<KikuBaseInfo>(KikuBaseInfo.class);
        util.exportExcel(response, list, "小鞠基本信息数据");
    }

    /**
     * 获取小鞠基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:baseInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kikuBaseInfoService.selectKikuBaseInfoById(id));
    }

    /**
     * 新增小鞠基本信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:baseInfo:add')")
    @Log(title = "小鞠基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KikuBaseInfo kikuBaseInfo)
    {
        return toAjax(kikuBaseInfoService.insertKikuBaseInfo(kikuBaseInfo));
    }

    /**
     * 修改小鞠基本信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:baseInfo:edit')")
    @Log(title = "小鞠基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KikuBaseInfo kikuBaseInfo)
    {
        return toAjax(kikuBaseInfoService.updateKikuBaseInfo(kikuBaseInfo));
    }

    /**
     * 删除小鞠基本信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:baseInfo:remove')")
    @Log(title = "小鞠基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kikuBaseInfoService.deleteKikuBaseInfoByIds(ids));
    }
}
